<template>

  <div class="container">    
		<div ref="formTitle" class="form-flex">
      <p>这是mutations直接改变state值</p>
      <p>我的名字是:  <span style="color:red">{{$storeVuex.state.name}}</span></p>
      <el-form :inline="true" class="demo-form-inline">
        <el-form-item label="改变我的名字是">
          <el-input v-model="name" placeholder="改变我的名字是"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="edit">确定</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div ref="formTitle" class="form-flex">
      <p>这是action直接改变state值</p>
      <p>我的名字是:  <span style="color:red">{{$storeVuex.state.name}}</span></p>
      <el-form :inline="true" class="demo-form-inline">
        <el-form-item label="改变我的名字是">
          <el-input v-model="name" placeholder="改变我的名字是"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="edit">确定</el-button>
        </el-form-item>
      </el-form>
    </div>
	</div>
  
</template>

<script>
import publics from '@/utils/public.js'
export default {
  data() {
    return {
      name:"",
    }
  },
  created () {
    // this.name = this.$storeVuex.state.name
    // console.log(this.$storeVuex.state.name)
  },
  methods: {
    edit(){
      this.$storeVuex.commit('nameFn',this.name);  //commit触发store里的函数
    }
  },
  mounted(){
  },
  
  computed: {

  }
}
</script>
<style>

  
</style>